package grape.crm.rest.customerassociatedcontactperson.mapper;

import grape.crm.rest.customerassociatedcontactperson.form.*;
import grape.crm.rest.customercontact.form.CustomerContactAttrCreateForm;
import grape.crm.rest.customercontact.form.CustomerContactCreateForm;
import grape.crm.service.customerassociatedcontactperson.param.AddCustomerAssociatedContactPersonParam;
import grape.crm.service.customerassociatedcontactperson.po.CustomerAssociatedContactPerson;
import grape.common.rest.mvc.WebMapper;
import grape.crm.service.customercontact.param.AddCustomerContactParam;
import org.mapstruct.Mapper;
import grape.crm.rest.customerassociatedcontactperson.vo.CustomerAssociatedContactPersonVo;
import org.mapstruct.ReportingPolicy;

import java.util.List;
import java.util.stream.Collectors;

/**
 * <p>
 * 关联联系人表 前端领域模型映射
 * </p>
 *
 * @author yangwei
 * @since 2020-09-24
 */
@Mapper(componentModel = "spring",unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface CustomerAssociatedContactPersonWebMapper extends WebMapper<CustomerAssociatedContactPersonVo, CustomerAssociatedContactPerson> {

    CustomerAssociatedContactPerson formToPo(CustomerAssociatedContactPersonCreateForm f);
    CustomerAssociatedContactPerson formToPo(CustomerAssociatedContactPersonUpdateForm f);
    CustomerAssociatedContactPerson formToPo(CustomerAssociatedContactPersonListPageForm f);
    CustomerAssociatedContactPerson formToPo(CustomerAssociatedContactPersonListForm f);

    AddCustomerAssociatedContactPersonParam formToParam(CustomerAssociatedContactPersonCreateForm f);
    AddCustomerAssociatedContactPersonParam formToParam(CustomerAssociatedContactPersonAttrCreateForm f);

    default List<AddCustomerAssociatedContactPersonParam> createFormsToParams(List<CustomerAssociatedContactPersonCreateForm> forms) {
        if (forms == null) {
            return null;
        }
        return forms.stream().map(this::formToParam).collect(Collectors.toList());
    }
    default List<AddCustomerAssociatedContactPersonParam> attrCreateFormsToParams(List<CustomerAssociatedContactPersonAttrCreateForm> forms) {
        if (forms == null) {
            return null;
        }
        return forms.stream().map(this::formToParam).collect(Collectors.toList());
    }
}
